package com.project.utils;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;
import android.util.DisplayMetrics;
import android.view.Display;

public class Utils {

	public static int[] getDeviceInfo(Activity context) {
		DisplayMetrics localDisplayMetrics = new DisplayMetrics();
		Display localDisplay = context.getWindowManager().getDefaultDisplay();
		localDisplay.getMetrics(localDisplayMetrics);
		int w = localDisplay.getWidth();
		int h = localDisplay.getHeight();
		int k = localDisplayMetrics.densityDpi;
		return new int[] { w, h, k };
	}

	public static boolean savePref(Context context, String key, String values) {
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
		Editor edit = prefs.edit();
		edit.putString(key, values);
		return edit.commit();

	}

	public static String getPref(Context context, String key, String defValue) {
		String value = "";
		try {
			SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
			value = prefs.getString(key, defValue);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return value;
	}
}
